package com.yang.dto;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.hmaill.pojo.Item;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.*;

@Data
@NoArgsConstructor
public class ItemDto {
    @TableId(type = IdType.AUTO)
    private Long id;//商品id
    private String name;//商品名称
    private Long price;//价格（分）
    private String image;//商品图片
    private String category;//分类名称
    private String brand;//品牌名称
    private Integer sold;//销量
    @TableField("isAD")
    private Boolean isAD;//商品状态 1-正常，2-下架

    @TableField("comment_count")
    private Integer commentCount;//评论数
    private List<String> suggestion = new ArrayList<>();


    public ItemDto(Item item) {
        this.id = item.getId();
        this.name = item.getName();
        this.image = item.getImage();
        this.price = item.getPrice();
        this.category = item.getCategory();
        this.brand = item.getBrand();
        this.sold = item.getSold();
        this.commentCount = item.getCommentCount();


        // 组装suggestion
        this.suggestion.add(this.name);
        this.suggestion.add(this.brand);
        this.suggestion.add(this.category);

    }
}
